home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0026_SETMODE2.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  3KB  |  84 lines

  1. {RV│ok i would like some info on how to remove a tsr added to memory by a
  2.   │i'd like some info on ext. VGA screens. For examplw i know that in
  3.   │320x200x256 that one Byte is equal to one pixel. i need this Type of
  4.   │info For =< 640x480
  5.  
  6. Mode $10 (ie 640x350x16)
  7. -------------------------
  8.  
  9. In this mode, the  256K display memory is divided into 4 bit planes of
  10. 64K each. Each pixel is produced by 4 bits, one from each bit plane, which
  11. are combined into a 4-bit value that determines which of the 16 colors will
  12. appear on the screen For that pixel.
  13.  
  14. There is a one-to-one correspondense between the bits in each bit plane and
  15. the pixel on the screen. For example, bit 7 of the first Byte in each bit
  16. plane correspond to the pixel in the upper left-hand corner of the screen.
  17.  
  18. The display memory For the 640x350 Graphics mode is mapped into memory as
  19. a 64K block starting at A000h, With each 64K bit plane occupying the same
  20. address space (ie: in parallel).
  21.  
  22. Because of the one-to-one relationship of bits in bit planes With the pixels
  23. on the screen, it's straightForward to calculate the address needed to
  24. access a particular pixel. There are 640 bits = 80 Bytes per line on the
  25. screen. Thus the Byte address corresponding to a particular X,Y coordinate
  26. is given by 80*Y + X/8. A desired pixel can then be picked out of the Byte
  27. using the bit mask register.
  28. }
  29.  
  30. Procedure PutPixel(X,Y:Integer; Color:Byte);
  31. Var
  32.   Byte_address : Word;
  33.   wanted_pixel        : Byte;
  34. begin
  35.   Port[$3CE] := 5;        (* mode register *)
  36.   Port[$3CF] := 2;        (* select Write mode 2 *)
  37.   Port[$3CE] := 8;        (* bit mask register *)
  38.                           (* calculate pixel's Byte address *)
  39.   Byte_address := (80 * Y) + (X div 8);
  40.                           (* set the bit we want *)
  41.   wanted_pixel := (1 SHL (7 - (X MOD 8)));
  42.                           (* mask pixel we want *)
  43.   Port[$3CF] := $FF and wanted_pixel;
  44.                           (* turn the pixel we want on *)
  45.   Mem[$A000:Byte_address] := Mem[$A000:Byte_address] or Color
  46. end; (* PutPixel *)
  47.  
  48. Function ActiveMode : Byte;
  49.   (* Returns the current display mode *)
  50. Var
  51.   Regs : Registers;     (* Registers from Dos Unit *)
  52. begin
  53.   Regs.AH := $0F;       (* get current video mode service *)
  54.   Intr($10,Regs);       (* call bios *)
  55.   ActiveMode := Reg.AL  (* current display mode returns in AL *)
  56. end;
  57.  
  58. {
  59. Some video numbers:
  60.  
  61.   CGA04         = $04;        (* CGA 320x200x4 *)
  62.   CGA06         = $06;        (* CGA 640x200x2 *)
  63.  
  64.   EGA0D         = $0D;        (* 320x200x16,EGA,2 pages (64K), A0000*)
  65.   EGA0E         = $0E;        (* 640x200x16,EGA,4 pages(64K)      " *)
  66.   EGA0F         = $0F;        (* 640x350 B&W,EGA,2 "     "        "  *)
  67.   EGA10         = $10;        (* 640x350x16 EGA,2 "    (128K)     " *)
  68.  
  69.   VGA11         = $11;        (* 640x480x2 B&W VGA, 4 pages (256K) " *)
  70.   VGA12         = $12;        (* 640x480x16  VGA   1 page  (256K) " *)
  71.   VGA13         = $13;        (* 320x200x256 VGA   4 pages (256K) " *)
  72.  
  73. Example:
  74.  
  75.   ...
  76.   if (ActiveMode = VGA13) then
  77.     begin
  78.       ....
  79.       ShowPCX256
  80.       ....
  81.     end
  82.   ...
  83. }
  84.